// pages/theme/theme.js

const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    btn: [],
    patbtn: [],
    imgheight: [],
    paint:[],
    btnheight: [],
    text: [],
    btnClick: []
  },

  hn1: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=12',
    })
  },
  hn2: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=14',
    })
  },
  hn3: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=15',
    })
  },
  hn4: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=16',
    })
  },
  hn5: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=17',
    })
  },
  hn6: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=18',
    })
  },
  hn7: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=19',
    })
  },
  hn8: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=20',
    })
  },
  hn9: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=21',
    })
  },
  hn10: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=23',
    })
  },
  hn11: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=24',
    })
  },
  hn12: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=25',
    })
  },
  hn13: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=28',
    })
  },

  ss1: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=2',
    })
  },
  ss2: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=3',
    })
  },
  ss3: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=10',
    })
  },
  ss4: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=11',
    })
  },
  ss5: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=22',
    })
  },
  ss6: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=26',
    })
  },
  ss7: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=29',
    })
  },
  ss8: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=30',
    })
  },
  ss9: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=31',
    })
  },
  ss10: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=32',
    })
  },

  rw1: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=5',
    })
  },
  rw2: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=4',
    })
  },
  rw3: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=8',
    })
  },
  rw4: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=9',
    })
  },
  rw5: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=13',
    })
  },
  rw6: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=27',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var from = options.from;
    var paints = [];
    var patBtn = [];
    var imgHeight = [];
    var btnHeight = [];
    var Btn=[];

    if(from == "hn"){
      wx.request({
        url: `${app.globalData.url}/painting/?pTheme=花鸟`,
        success: res=>{
          var arr = res.data.data;
          for(var i=0; i<arr.length; i++){
            paints.push(`${app.globalData.url}/pContent/?pId=${arr[i].pId}`);
            if(i==5 || i==9){
              imgHeight.push('1000rpx')
              btnHeight.push("900rpx")
            }else if( i==10 ){
              imgHeight.push('780rpx')
              btnHeight.push("780rpx")
            }else{
              imgHeight.push('400rpx')
              btnHeight.push("400rpx")
            }
          }
          for(var i=0; i<13; i++){
            patBtn.push('block');
            Btn.push('flex')
          }
          this.setData({
            paint: paints,
            patbtn: patBtn,
            imgheight: imgHeight,
            btnheight: btnHeight,
            btn: Btn,
            btnClick: ["hn1","hn2","hn3","hn4","hn5","hn6","hn7","hn8","hn9","hn10","hn11","hn12","hn13"]
          })
        }
      })
    }else if(from == "ss"){
      wx.request({
        url: `${app.globalData.url}/painting/?pTheme=山水`,
        success: res=>{
          var arr = res.data.data;
          for(var i=0; i<arr.length; i++){
            paints.push(`${app.globalData.url}/pContent/?pId=${arr[i].pId}`);
            if(i==1){
              imgHeight.push('1200rpx')
              btnHeight.push("1200rpx")
            }else if(i==6){
              imgHeight.push('200rpx')
              btnHeight.push("200rpx")
            }else if( i==4 || i==7 || i==8){
              imgHeight.push('800rpx')
              btnHeight.push("800rpx")
            }else if( i==9){
              imgHeight.push('1850rpx')
              btnHeight.push("1850rpx")
            }else{
              imgHeight.push('400rpx')
              btnHeight.push("400rpx")
            }
          }
          for(var i=0; i<13; i++){
            if(i<10){
              patBtn.push('block');
              Btn.push('flex')
            }else{
              patBtn.push("none");
              Btn.push("none")
            }
          }
          this.setData({
            paint: paints,
            patbtn: patBtn,
            imgheight: imgHeight,
            btnheight: btnHeight,
            btn: Btn,
            btnClick: ["ss1", "ss2", "ss3","ss4", "ss5", "ss6","ss7", "ss8", "ss9","ss10"]
          })
        }
      })
    }else if(from == "rw"){
      wx.request({
        url: `${app.globalData.url}/painting/?pTheme=人物`,
        success: res=>{
          var arr = res.data.data;
          for(var i=0; i<arr.length; i++){
            paints.push(`${app.globalData.url}/pContent/?pId=${arr[i].pId}`);
            console.log(arr[i].pId)
            if(i==2){
              imgHeight.push('200rpx')
              btnHeight.push("200rpx")
            }else if( i==6 || i==8){
              imgHeight.push('1050rpx')
              btnHeight.push("1050rpx")
            }else{
              imgHeight.push('400rpx')
              btnHeight.push("400rpx")
            }
          }
          for(var i=0; i<13; i++){
            if(i<6){
              patBtn.push('block');
              Btn.push('flex')
            }else{
              patBtn.push("none");
              Btn.push("none")
            }
          }
          this.setData({
            paint: paints,
            patbtn: patBtn,
            imgheight: imgHeight,
            btnheight: btnHeight,
            btn: Btn,
            btnClick: ["rw1","rw2","rw3","rw4","rw5","rw6"]
          })
        }
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})